package com.example.consumeexample.listener;

import com.example.common.QueueConsts;
import com.example.common.UserEvent;
import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * 消息监听.
 *
 * @author Luo
 * @version 3.7.0
 * @date 2021/6/24 19:21
 **/
@Slf4j
@Component
public class ConsumeListener {

    /**
     * 监听用户队列消息.
     *
     * @param userEvent 消息
     * @param channel   通道信息
     * @param message   附加的参数信息
     */
    @RabbitListener(queues = QueueConsts.USER_QUEUE_NAME)
    public void receiveMessage(UserEvent userEvent, Channel channel, Message message) {
        log.info("接收到消息：{}", userEvent);
    }


}

